package com.ruoyi.system.controller;

import java.util.List;
import java.util.Map;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.system.domain.SpffVideos;
import com.ruoyi.system.service.IBigScreenService;

/**
 * 数据大屏Controller
 * 
 * @author ruoyi
 * @date 2025-10-15
 */
@RestController
@RequestMapping("/system/bigscreen")
public class BigScreenController extends BaseController
{
    @Autowired
    private IBigScreenService bigScreenService;

    /**
     * 获取地图数据（用户分布或视频分布）
     * @param type 数据类型：user-用户分布, video-视频分布
     */
    @PreAuthorize("@ss.hasPermi('system:bigscreen:query')")
    @GetMapping("/map-data")
    public AjaxResult getMapData(@RequestParam(defaultValue = "user") String type)
    {
        List<Map<String, Object>> mapData = bigScreenService.getMapData(type);
        return success(mapData);
    }

    /**
     * 获取热度视频TOP排行榜
     * @param size 返回数量，默认10
     */
    @PreAuthorize("@ss.hasPermi('system:bigscreen:query')")
    @GetMapping("/hot-videos")
    public TableDataInfo getHotVideos(@RequestParam(defaultValue = "10") Integer size)
    {
        List<SpffVideos> list = bigScreenService.getHotVideos(size);
        return getDataTable(list);
    }

    /**
     * 获取实时统计数据
     */
    @PreAuthorize("@ss.hasPermi('system:bigscreen:query')")
    @GetMapping("/real-time-stats")
    public AjaxResult getRealTimeStats()
    {
        Map<String, Object> stats = bigScreenService.getRealTimeStats();
        return success(stats);
    }
}

